<template>
	<view class="container">
		<!-- 页面标题 -->
		<view class="page-title">服务评价</view>
		
		<!-- 门店信息 -->
		<view class="store-info">
			<image class="store-image" src="/static/order/门店.png"></image>
			<view class="store-name">车百事汽车生活馆</view>
		</view>
		
		<!-- 评分区域 -->
		<view class="rating-section">
			<view class="section-title">评分</view>
			<view class="stars">
				<image 
					v-for="(star, index) in 5" 
					:key="index" 
					class="star" 
					:src="'/static/order/五星 拷贝 5.png'"
				></image>
			</view>
		</view>
		
		<!-- 评语区域 -->
		<view class="comment-section">
			<view class="section-title">
				评语 (0-299字)
				<text class="word-count">{{comment.length}}/299</text>
			</view>
			<textarea 
				class="comment-input" 
				placeholder="请留下您宝贵的意见和建议……" 
				placeholder-class="placeholder"
				maxlength="299"
				v-model="comment"
			></textarea>
		</view>
		
		<!-- 分隔线 -->
		<view class="divider"></view>
		
		<!-- 照片上传区域 -->
		<view class="upload-section">
			<view class="section-title">照片 (选填)</view>
			<view class="upload-area">
				<view class="upload-btn" @click="chooseImage">
					<image class="plus-icon" src="/static/order/加号.png"></image>
					<text>上传照片</text>
				</view>
				<view class="image-preview" v-for="(image, index) in images" :key="index">
					<image class="preview-image" :src="image" mode="aspectFill"></image>
					<view class="delete-btn" @click="deleteImage(index)">×</view>
				</view>
			</view>
		</view>
		
		<!-- 提交按钮 -->
		<view class="submit-btn-container">
			<button class="submit-btn" @click="submitEvaluation">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				comment: '',
				images: []
			};
		},
		methods: {
			chooseImage() {
				uni.chooseImage({
					count: 9 - this.images.length,
					sizeType: ['original', 'compressed'],
					sourceType: ['album', 'camera'],
					success: (res) => {
						this.images = this.images.concat(res.tempFilePaths);
					}
				});
			},
			deleteImage(index) {
				this.images.splice(index, 1);
			},
			submitEvaluation() {
				if (this.comment.trim() === '') {
					uni.showToast({
						title: '请填写评语',
						icon: 'none'
					});
					return;
				}
				
				uni.showToast({
					title: '评价提交成功',
					icon: 'success'
				});
				
				// 实际项目中这里应该有提交评价的API调用
				setTimeout(() => {
					uni.navigateBack();
				}, 1500);
			}
		}
	};
</script>

<style>
	.container {
		padding: 0;
		font-size: 14px;
		line-height: 24px;
		background-color: #f5f5f5;
		min-height: 100vh;
	}
	
	.page-title {
		padding: 15px;
		background-color: #fff;
		font-size: 18px;
		font-weight: bold;
		text-align: center;
		border-bottom: 1px solid #eee;
	}
	
	.store-info {
		padding: 20px 15px;
		background: #fff;
		display: flex;
		align-items: center;
		margin-bottom: 10px;
	}
	
	.store-image {
		width: 40px;
		height: 40px;
		border-radius: 4px;
		margin-right: 10px;
	}
	
	.store-name {
		font-size: 16px;
		font-weight: bold;
	}
	
	.rating-section {
		padding: 15px;
		background: #fff;
		margin-bottom: 10px;
	}
	
	.comment-section {
		padding: 15px;
		background: #fff;
		margin-bottom: 10px;
	}
	
	.section-title {
		font-size: 16px;
		font-weight: bold;
		margin-bottom: 15px;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.word-count {
		font-size: 12px;
		color: #999;
		font-weight: normal;
	}
	
	.stars {
		display: flex;
		justify-content: center;
	}
	
	.star {
		width: 30px;
		height: 30px;
		margin: 0 5px;
	}
	
	.comment-input {
		width: 100%;
		height: 120px;
		padding: 10px;
		border: 1px solid #eee;
		border-radius: 4px;
		font-size: 14px;
		box-sizing: border-box;
	}
	
	.placeholder {
		color: #999;
	}
	
	.divider {
		height: 1px;
		background: #f0f0f0;
		margin: 15px 0;
	}
	
	.upload-section {
		padding: 15px;
		background: #fff;
		margin-bottom: 10px;
	}
	
	.upload-area {
		display: flex;
		flex-wrap: wrap;
	}
	
	.upload-btn {
		width: 80px;
		height: 80px;
		border: 1px dashed #ddd;
		border-radius: 4px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-right: 10px;
		margin-bottom: 10px;
	}
	
	.plus-icon {
		width: 20px;
		height: 20px;
		margin-bottom: 5px;
	}
	
	.image-preview {
		width: 80px;
		height: 80px;
		margin-right: 10px;
		margin-bottom: 10px;
		position: relative;
	}
	
	.preview-image {
		width: 100%;
		height: 100%;
		border-radius: 4px;
	}
	
	.delete-btn {
		position: absolute;
		top: -8px;
		right: -8px;
		width: 20px;
		height: 20px;
		background: #ff3b30;
		color: #fff;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 16px;
	}
	
	.submit-btn-container {
		padding: 20px 15px;
		background: #fff;
	}
	
	.submit-btn {
		background: #007aff;
		color: #fff;
		border: none;
		border-radius: 4px;
		padding: 12px 0;
		font-size: 16px;
	}
</style>